<template>
  <div>
    <input ref="inputFile" type="file" style="display: none" @change="inputFile" />
    <el-button @click="handleClick">上传文件</el-button>
  </div>
</template>
<script>
import request from '@/router/axios'
export default {
  components: {},
  data() {
    return {}
  },
  created() {},
  mounted() {},
  methods: {
    handleClick() {
      this.$refs.inputFile.click()
    },
    inputFile(e) {
      let file = e.target.files[0]
      let format = new FormData()
      format.append('file', file)
      console.log(format)
      request({
        url: `/cp/common/upload-test`,
        method: 'post',
        data: format
      }).then((res) => {
        console.log(res)
        let url = res.data.data.url
        this.$copyText(`${location.origin}${url}`).then(
          (e) => {
            //
          },
          (e) => {
            //
          }
        )
        // res = res.data
        // if (res.code === 0 && res.data) {
        //   callback && callback(res.data)
        // }
      })
    }
  }
}
</script>
<style scoped lang='scss'>
</style>